package main
 
import(
    "log"
    "net/smtp"
    "flag"
    "fmt"
	"strings"
)
 
var (
    subject = flag.String( "s","","subject of the mail" )
    body= flag.String( "b","","body of themail" )
    //reciMail = flag.String( "m","","gouihk@126.com" )
)
 
func main() {
        // Set up authentication information.
        flag.Parse()
        sub := fmt.Sprintf("subject: %s\r\nContent-Type:text/html;charset=UTF-8\r\n",*subject)
        //content :=  *body
	content :="<html><META content='text/html; charset=UTF-8' http-equiv=Content-Type><body><h3>Test send email by golang</h3><a href='#'>baidu</a></body></html>"
        //mailList := strings.Split( *reciMail,",")
	to := strings.Split("gouihk@126.com;lingjip@gmail.com",";");
        
        auth := smtp.PlainAuth(
                "",
                "lingjip@gmail.com",
                "1181151539",
                "smtp.gmail.com",
                //"smtp.gmail.com",
        )
        // Connect to the server, authenticate, set the sender and recipient,
        // and send the email all in one step.
        err := smtp.SendMail(
                "smtp.gmail.com:25",
                auth,
                "lingjip@gmail.com",
                to,
                []byte(sub+content),)
        if err != nil {
                log.Fatal(err)
        }
}
